package com.pinyou.item.mapper;


import com.pinyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Title: BrandMapper
 * @Description:
 * @Auther:jzfai
 * @Version: 1.0
 * @create 2020/3/4 12:49
 */
public interface BrandMapper extends Mapper<Brand> {
    /**
     * 新增商品分类和品牌中间表数据
     * @param cid 商品分类id

     * @return
     */
    @Insert("INSERT INTO tb_category_brand(category_id,brand_id) VALUES(#{cid},#{bid})")
    int inserBrandAndCategory(@Param("cid") Long cid,@Param("bid") Long bid);

    @Select("SELECT b.* from tb_category_brand cb\n" +
            "JOIN tb_brand b\n" +
            "ON cb.brand_id =b.id\n" +
            "WHERE cb.category_id=#{cid}")
    List<Brand> selectBrandByCid(Long cid);
}
